package com.juc.scheduledExecutorService.scheduledExecutorService4;

import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;

public class Run {

	//scheduleAtFixedRate周期性的运行
	// 执行任务的时间大于 period 预定的周期时间，也就是产生了超时的效果
	public static void main(String[] args) {
		ScheduledExecutorService executorService = Executors.newSingleThreadScheduledExecutor();
	    System.out.println("  X= " + System.currentTimeMillis());
	    executorService.scheduleAtFixedRate(new MyRunnable(), 1, 2, TimeUnit.SECONDS);
	    System.out.println("  Y= " + System.currentTimeMillis());

	}
}
